<%@ page import="com.example.mystore.entity.Commodity" %>
<%@ page import="java.util.HashMap" %>
<%@ page import="java.util.Map" %>
<%@ page import="java.text.DecimalFormat" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<html>
<head>
    <title>订单页面</title>
    <link rel="stylesheet" href="css/header.css">
    <link rel="stylesheet" href="css/footer.css">
    <style>
        * { margin: 0;padding: 0}
        .banner { width: 1350px;height: 720px;border: 1px solid #bdb9b9;margin: 20px auto}
        .bannerHeader { width: 100%;height: 40px;background-color: #d0cfcf}
        .bannerHeader .headerLeft { font-size: 20px;line-height: 40px;margin-left: 10px;color: #4c4a4a}
        .bannerHeader .headerRight { font-size: 12px;line-height: 40px;float: right;color: red}
        .bannerList {width: 66%;height: 400px;border: 1px solid darkorange;margin: 20px auto}
        .banner .bannerMain { width: 95%;height: 370px;margin: 20px auto;overflow: scroll}
        .banner .bannerMain::-webkit-scrollbar {display:none}
        .bannerInfo { width: 240px;height: 120px;margin-left: 800px}
        .bannerInfo tr { height: 30px}
        .banner .btn { margin:30px auto;width: 400px;height: 50px;position: relative}
        .banner .btn button {width: 180px;height: 40px;background-color: #e01f1f;border: white;color: white;cursor: pointer;}
        .banner .btn .confirm { position: absolute;right: 0}
    </style>
</head>
<body>
<header id="header">
    <div id="headerBox">
        <h1>品优购</h1>
        <a href="display.jsp">返回首页</a>
        <a href="">联系客服</a>
    </div>
</header>
<div class="banner">
    <div class="bannerHeader">
        <span class="headerLeft">订单信息</span>
        <span class="headerRight">步骤三</span>
    </div>
    <div class="bannerList">
        <div class="bannerMain">
            <table>
                <tr>
                    <th width="510px">产品名称</th>
                    <th width="146px">数量</th>
                    <th width="146px">单价</th>
                    <th width="146px">小计</th>
                </tr>
                <%  int countNumb = 0;
                    double countPrice = 0.00;
                    HashMap<Commodity,Integer> cart = (HashMap<Commodity, Integer>) request.getSession().getAttribute("cart");
                    if(cart != null){%>
                <%for (Map.Entry<Commodity,Integer> entry: cart.entrySet()){%>
                <%countNumb += entry.getValue();
                    countPrice += entry.getKey().getPrice()*entry.getValue();%>
                <tr class="order">
                    <td width="400px" style="text-align: center"><%=entry.getKey().getName()%></td>
                    <td width="110px" style="text-align: center"><%=entry.getValue()%></td>
                    <td width="110px" style="text-align: center"><%=entry.getKey().getPrice()%></td>
                    <td width="110px" style="text-align: center"><%=new DecimalFormat("#0.00").format(entry.getKey().getPrice()*entry.getValue())%></td>
                </tr>
                <%}
                }%>
            </table>
        </div>
    </div>
    <div class="bannerInfo">
        <table>
            <tr>
                <th style="width: 90px;text-align: left">小计：</th>
                <th style="text-align: left">￥<%=new DecimalFormat("#0.00").format(countPrice)%></th>
            </tr>
            <tr>
                <th style="width: 90px;text-align: left">税额：</th>
                <th style="text-align: left">￥<%=new DecimalFormat("#0.00").format(countPrice/1000)%></th>
            </tr>
            <tr>
                <th style="width: 90px;text-align: left">送货额：</th>
                <th style="text-align: left">￥<%=new DecimalFormat("#0.00").format(countNumb*5)%></th>
            </tr>
            <tr>
                <th style="width: 90px;text-align: left">总计：</th>
                <th style="color: #fc5531;font-size: 25px;text-align: left">￥<%=new DecimalFormat("#0.00").format(countPrice+(countPrice/1000)+(countNumb*5))%></th>
            </tr>
        </table>
    </div>
    <div class="btn">
        <a href="payMassage.jsp"><button>上一步</button></a>
        <a href="${pageContext.request.contextPath}/Pay"><button class="confirm">确认</button></a>
    </div>
</div>
<footer id="footer">
    <div id="footerBox">
        <div class="">
            <a  href="">
                关于我们
            </a>
            |
            <a href="">
                联系我们
            </a>
            |
            <a href="">
                人才招聘
            </a>
            |
            <a  href="">
                商家入驻
            </a>
            |
            <a href="">
                广告服务
            </a>
            |
            <a  href="">
                友情链接
            </a>
            |
            <a  href="">
                销售联盟
            </a>
            |
            <a href="" >
                商家社区
            </a>
            |
            <a href="" >
                捐款公益
            </a>
        </div>
        <div class="">
            1107841498@qqcom&nbsp;©&nbsp;&nbsp;&nbsp;&nbsp;版权归<a href="">@清秋</a>所有
        </div>
    </div>
</footer>
</body>
</html>
